﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Modeling.Validation;

namespace DSLFactory.VSCTDesigner
{
    [ValidationState(ValidationState.Enabled)]
    partial class CommandWithIcon
    {
        [ValidationMethod(ValidationCategories.Save)]
        void Validate(ValidationContext context)
        {
            ValidationHelper.MustHaveStrings(context, this);
        }
    }

    [ValidationState(ValidationState.Enabled)]
    partial class ExternCommand
    {
        [ValidationMethod(ValidationCategories.Save)]
        void Validate(ValidationContext context)
        {
            ValidationHelper.NotNullOrEmpty(context, this.Guid, "Guid", this);
            ValidationHelper.NotNullOrEmpty(context, this.ID, "ID", this);
            ValidationHelper.ValidateExternGuidExists(context, this);
        }
    }

    [ValidationState(ValidationState.Enabled)]
    partial class Command
    {
        [ValidationMethod(ValidationCategories.Save)]
        void Validate(ValidationContext context)
        {
            ValidationHelper.NotNullOrEmpty(context, this.Guid, "Guid", this);
            ValidationHelper.NotNullOrEmpty(context, this.ID, "ID", this);
        }
    }

    [ValidationState(ValidationState.Enabled)]
    partial class Combo
    {
        [ValidationMethod(ValidationCategories.Save)]
        void ValidateIdList(ValidationContext context)
        {
            ValidationHelper.ValidId(context, this.IdCommandList, "IdCommandList", this);
            ValidationHelper.NotZero(context, this.DefaultWidth, "DefaultWidth", this);
        }
    }

    [ValidationState(ValidationState.Enabled)]
    partial class StringDef
    {
        [ValidationMethod(ValidationCategories.Save)]
        void Validate(ValidationContext context)
        {
            ValidationHelper.MustHaveButtonText(context, this);
        }
    }

    [ValidationState(ValidationState.Enabled)]
    partial class KeyBindingElement
    {
        [ValidationMethod(ValidationCategories.Save)]
        void Validate(ValidationContext context)
        {
            ValidationHelper.NotNullOrEmpty(context, this.Editor, "Editor", this);
            ValidationHelper.NotNullOrEmpty(context, this.Key1, "Key1", this);
            if( this.Mod2 != KeyModifier.None)
                ValidationHelper.NotNullOrEmpty(context, this.Key2, "Key2", this);
        }
    }
}
